const User = require('../../db/userSchame');
module.exports = async(req, res) => {
    console.log(req.body.id);
    // 让数据库删除数据
    try {
        var rel = await User.deleteOne({ "_id": req.body.id });
        console.log(rel);
        // { deletedCount: 0 }
        // { deletedCount: 1 }
        if (rel.deletedCount) {
            res.redirect('/admin/userlist');
        } else {
            res.send('<script>alert("此用户信息不符,删除失败")</script>')
        };
    } catch (error) {
        res.status(500).send('删除失败' + error);
    }

};